<template name="qiyexinxi-card">
	<!-- 企业信息列表项 -->
	<view class="text-card">
		<view class="card-row card-title">
			<text class="glyphicon glyphicon-play" style="margin-right: 10px;"></text>
			{{auser.username}}
		</view>	
		<view class="card-row">
			<view class="row-label w20">评分日期</view>
			<view class="row-content w50">{{auser.yuyuedate || '未预约'}}</view>
		</view>	
		<view class="card-row">
			<view class="row-label w20">地址</view>
			<view class="row-content w80">{{auser.jingyingdizhi}}</view>
		</view>
		<view class="card-row" @click="callPhone(auser.lianxirentel)">
			<view class="row-label w20">联系人</view>
			<view class="row-content w30">{{auser.lianxiren}}</view>
			<view class="row-label w20">联系电话</view>
			<view class="row-content w30 f16">{{auser.lianxirentel}}</view>
		</view>
		<view class="card-row" @click="callPhone(auser.farentel)">
			<view class="row-label w20">法人</view>
			<view class="row-content w30">{{auser.faren}}</view>
			<view class="row-label w20">联系电话</view>
			<view class="row-content w30 f16">{{auser.farentel}}</view>
		</view>
		<view class="card-row" @click="callPhone(auser.fsdtel)" v-if="auser.fsd == 1">
			<view class="row-label w20">安全总监</view>
			<view class="row-content w30">{{auser.fsdName}}</view>
			<view class="row-label w20">联系电话</view>
			<view class="row-content w30 f16">{{auser.fsdTel}}</view>
		</view>
		<view class="card-row">
			<view class="row-label w20">信用代码</view>
			<view class="row-content w50">{{auser.userno}}</view>
			<view class="w30" style="text-align: right;">
				<u-button type="primary" size="mini" @click="handleViewCompany">查看企业</u-button>
			</view>
		</view>	
		<view class="card-row">
			<view class="row-label w20">许可证号</view>
			<view class="row-content w50">{{auser.xukezhenghao}}</view>
			<view class="w30" style="text-align: right;">
				<u-button :type="recordCount == 0 ? 'primary' : 'success'" size="mini" @click="handleClick">{{buttonTextFormat}}</u-button>
			</view>
		</view>
		<view class="card-row">
			<view class="row-label w20">初评分级</view>
			<view class="row-content w50">
				<u-rate v-model="scoreRating" :disabled="true"></u-rate>
			</view>
			<view class="w30" style="text-align: right;">
				<u-button :type="visitCount == 0 ? 'primary' : 'info'" size="mini" @click="toVisitPage">企业登记</u-button>
			</view>
		</view>
		<!-- 评分前，填写《走访记录表》 
		2025 填写《企业登记表》（曾用名：经营情况登记表），按钮放在上面一行了 -->
		<!-- 评分后，填写《量化分级现场评审结果记录表》
		2025 不填 -->
		<view class="card-row">
			<!-- <view class="w50" style="text-align: center;">
				<u-button :type="visitCount == 0 ? 'primary' : 'info'" size="mini" @click="toVisitPage">填写走访记录表</u-button>
			</view>
			<view class="w50" style="text-align: center;">
				<u-button :type="resultCount == 0 ? 'primary' : 'info'" size="mini" @click="toResultPage">填写现场评审结果记录</u-button>
			</view> -->
		</view>
		<view class='cu-tag line-blue m-tag'>{{statusText}}</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				//状态（0未受理、1已受理、2已评定（可修改现场评分）、3已审核（不可修改现场评分）、4已公示、10作废）
			}
		},
		props:{
			id:'',
			auser:{},
			formId: '',
			recordFormId: '',
			status: '',
			expertEvaluateStatus: '',
			assessStartDate: null,
			assessEndDate: null,
			expertIds: '',
			assessorNumber: '',
			scoreRating: 0,
			visitCount: 0,
			resultCount: 0,
			recordCount: 0,
		},
		computed:{
			//状态（0未受理（待分配）、1已受理、2已评定（可修改现场评分）、3已审核（不可修改现场评分）、4已公示、10作废）
			statusText: function(){
				switch(this.$props.status){
					case '0':
						return '申  报  中';
						break;
					case '1':
						return '待  分  配';
						break;
					case '2': // 已分配（非本人，无评分按钮）、待评分（本人，有评分按钮）
						let s1 = this.$props.expertIds && this.$props.expertIds.indexOf(vk.getVuex('$user.userInfo.userId')) >= 0 ? '待  评  分' : '已  分  配'
						return this.$props.expertEvaluateStatus == 1 ? '已  评  分' : s1;
						break;
					case '3':
						let s2 = this.$props.expertIds && this.$props.expertIds.indexOf(vk.getVuex('$user.userInfo.userId')) >= 0 ? '待  评  分' : '已  分  配'
						return this.$props.expertEvaluateStatus == 1 ? '已  评  分' : s2;
						break;
					case '4':
						return '已  审  核'
						break;
					case '5':
						return '已  公  示'
						break;
					// case '5':
					// 	let full = this.$props.assessorNumber && this.$props.expertIds && this.$props.expertIds.split(',').length == this.$props.assessorNumber
					// 	let text = full ? '报 名 结 束' : '报  名  中';
					// 	text = this.$props.expertIds && this.$props.expertIds.indexOf(vk.getVuex('$user.userInfo.userId')) >= 0 ? '已  报  名' : text
					// 	return text;
					// 	break;
					default:
						return ''
				}
			},
			buttonTextFormat(){
				switch(this.$props.status){
					case '0':
						return '查看';
						break;
					case '1':
						return '查看';
						break;
					case '2':
						return '评分';
						break;
					case '3':
						return '修改评分'
						break;
					case '4':
						return '查看'
						break;
					case '5':
						return '已公示'
						break;
					// case '5':
					// 	return '公益评审报名'
					// 	break;
					case '8':
						return '已建档'
						break;
					default:
						return '' + this.$props.status
				}
			}
		},
		mounted() {
			
		},
		methods:{
			handleClick(){
				if(this.$props.status == 5){  //报名
					uni.navigateTo({
						url: '/pages/score/enroll?evaluateId=' + this.$props.id
					})
				}
				else{  // 评分、查看评分
					uni.navigateTo({
						url: '/pages/score/score?evaluateId=' + this.$props.id
					})
				}
			},
			handleViewCompany(){
				uni.navigateTo({
					url: '/pages/company/info?auser=' + encodeURIComponent(JSON.stringify(this.$props.auser))
				})
			},
			toVisitPage(){
				// uni.navigateTo({
				// 	url: '/pages/score/visit',
				// 	success: (res) => {
				// 		// 通过eventChannel向被打开页面传送数据
				// 		res.eventChannel.emit('data', {
				// 			evaluateId: this.$props.id,
				// 			companyId: this.$props.auser.id,
				// 			companyName: this.$props.auser.username,
				// 			companyAddress: this.$props.auser.jingyingdizhi,
				// 			contactName: this.$props.auser.lianxiren,
				// 			contactTel: this.$props.auser.lianxirentel,
				// 			xukezhenghao: this.$props.auser.xukezhenghao,
				// 			personQuantity: this.$props.auser.personQuantity,
				// 			fsd: this.$props.auser.fsd,
				// 			fsdName: this.$props.auser.fsdName,
				// 			fsdTel: this.$props.auser.fsdTel,
				// 			operatingArea: this.$props.auser.operatingArea,
				// 			cuisine: this.$props.auser.cuisine
				// 		})
				// 	}
				// })
				vk.navigateTo({
					url: '/pages/business/detail',
					success: (res) => {
						// 通过eventChannel向被打开页面传送数据
						res.eventChannel.emit('data', {
							// evaluateId: this.$props.id,
							companyId: this.$props.auser.id,
							companyName: this.$props.auser.username,
							xukezhenghao: this.$props.auser.xukezhenghao,
							contactName: this.$props.auser.lianxiren,
							contactTel: this.$props.auser.lianxirentel,
							companyAddress: this.$props.auser.jingyingdizhi,
							shi: this.$props.auser.shi,
							qu: this.$props.auser.qu,
						})
					}
				})
			},
			toResultPage(){
				uni.navigateTo({
					url: '/pages/score/results',
					success: (res) => {
						// 通过eventChannel向被打开页面传送数据
						res.eventChannel.emit('data', {
							evaluateId: this.$props.id,
							companyId: this.$props.auser.userno,
							companyName: this.$props.auser.username,
							year: this.$props.auser.createdate.substr(0,4),
						})
					}
				})
			},
			// 拨打电话
			callPhone(tel) {
				if(tel) uni.makePhoneCall({
					phoneNumber: tel
				})
			},
		}
	}
</script>

<style>
	@import url("/static/css/main.css");
	.m-tag{
		position: absolute;
		top: 30px;
		bottom: 20px;
		left: 0upx;
		right: 0upx;
		margin: auto;
		width: 180upx;
		transform: rotate(15deg);
		/* letter-spacing: 10px; */
		font-weight: 700;
	}
	.text-card{
		position: relative;
	}
	.cu-tag{
		/* justify-content: initial; */
		display: flex;
		align-items: center;
		color: blue;
	}
</style>
